Mathematica 遗传算法的思路和部分程序

为了节省空间,染色体和基因用整数表示,运算的时候看成二进制就是了,应该可以大大提高速度

随机创建种群:

GANewGroup[n_:50,l_:16]:=Table[RandomInteger[2^l],n];

基因解码(这里按照自己的编码方式改成自己的):

GADecode[x_]:=x*0.00003051757813;

适应度(改成自己的):

GAFitness[x_]:=(2-x)Exp[x];

染色体交叉互换,n是位置:

GACross[x_,y_,n_]:={x-#1+#2,y-#2+#1}&@@Mod[{x,y},2^n];

暂时这些 其他内容有时间再补充

使用举例:

group=GANewGroup[100,16];(*生成染色体长度16,100个个体的种群*)
fitness=RankedMax[GAFitness/@group,Floor[0.8*Length@group]];(*计算淘汰20%个体的适应度*)
group=DeleteCases[group,x_/;GAFitness@x<fitness];(*淘汰个体*)
(*繁殖新的个体*)
(*......*)

 

Mathematica 是数学领域的一个巨人,发布的 Mathematica 软件在各个前沿行业的科学计算,仿真,建模等应用中发挥着关键作用。 我下载了45个典型的 Mathematica 演示范例,供打包下载学习。 AreTheseLinesStraight-source.nb BoilingPointOfWaterOnSeveralPlanets-source.nb CassiniSpaceflight-source.nb CellularAutomataOnTrivalentNetworks-source.nb CIEChromaticityDiagram-source.nb CogwheelDrive-source.nb ComplexAdditionOfHarmonicMotionsAndThePhenomenonOfBeats-source. CosineOffsetCurves-source.nb CurlicueFractal-source.nb DayAndNightWorldClock-source.nb DigitalTiltShiftPhotography-source.nb Emoticon-source.nb IcosahedronBall-source.nb InsulinMolecule-source.nb JackLewSignatureFunction-source.nb KeyboardAndComposer-source.nb KomanVariations-source.nb LengthScalesInTheSolarSystem-source.nb LeonardoDaVincisOrnithopter-source.nb LookingAtACube-source.nb MicrowaveOven-source.nb MosaicEffectForPhotographicImages-source (1).nb MosaicEffectForPhotographicImages-source.nb Mountainscape-source.nb PicturePuzzle-source.nb PicturePuzzle.cdf PolynomialAndDerivative-source.nb RadialEngine-source.nb ReliefShadedElevationMap-source.nb SaturnsSeasonalSundial-source.nb SegmentingAMedicalImage-source.nb SmileyChanger-source.nb SpringReturnButton-source.nb SunflowerSeedArrangements-source.nb SunflowerSeedArrangements-source.pdf SurfaceWithBranchCuts-source.nb TermWeightingWithTFIDF-source.nb TheUlamPrimeSpiral-source.nb ThickeningAPolygonMeshForRapidPrototyping3DPrinting-source.nb TravelingSalesmanArt-source.nb TreeBender-source.nb Tries-source.nb TwentyDodecahedronTowers-source.nb VoronoiImage-source.nb WhirlingPolygons-source.nb
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值